package com.ant.storage.controller;


import com.ant.storage.common.ResultVo;
import com.ant.storage.dto.SupplysideAccessoriesDto;
import com.ant.storage.handler.AntException;
import com.ant.storage.service.ISupplysideAccessoriesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hzd
 * @since 2025-10-31
 */
@Api(tags = "工业企业产品信息接口")
@RestController
@RequestMapping("/supplySideAccessories")
public class SupplysideAccessoriesController {

    @Autowired
    ISupplysideAccessoriesService accessoriesService;


    @ApiOperation(value = "保存信息")
    @PostMapping("/save")
    public ResultVo save(@RequestBody SupplysideAccessoriesDto dto)
    {
        accessoriesService.save(dto);
        return ResultVo.success("添加成功");
    }

    @ApiOperation(value = "通过产品id获取辅料列表")
    @GetMapping("/listById")
    @ApiImplicitParam(name = "id", value = "产品id", required = true,dataType = "Integer", paramType = "query")
    public ResultVo listById(Integer id){
        if(id==null){
            throw new AntException("请输入产品id");
        }
        return ResultVo.success("ok",accessoriesService.listById(id));
    }
}
